package com.yunzone.cloud.module.order;


import com.yunzone.cloud.common.entity.Result;
import com.yunzone.cloud.modules.payment.entity.Payment;
import jdk.nashorn.internal.objects.annotations.Getter;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

@RestController
@RequestMapping("/order")
public class OrderController {

    //private static final String PAYMENT_ADDR="http://127.0.0.1:8001/payment";
    private static final String PAYMENT_ADDR="http://CLOUD-PAYMENT-SERVICE";


    @Resource
    private RestTemplate restTemplate;

    @GetMapping("/query/{id}")
    public Result<Payment> queryOrder(@PathVariable("id") long id){
        return restTemplate.getForObject(PAYMENT_ADDR+"/payment/query/"+id,Result.class);
    }

    @GetMapping("/create")
    public Result<Payment> queryOrder(Payment payment){
        return restTemplate.postForObject(PAYMENT_ADDR+"/payment/add/",payment,Result.class);
    }

}
